package com.wzw.expression.record.expression;

import com.wzw.expression.expression.operation.AnnotationOperationProvider;
import com.wzw.expression.expression.operation.Operation;
import com.wzw.expression.record.annotations.IRecords;

import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Collectors;

/**
 * @author Wangzhiwen
 */
public class IRecordsAnnotationOperationProvider implements AnnotationOperationProvider {
    @Override
    public Class<? extends Annotation> getType() {
        return IRecords.class;
    }

    @Override
    public Collection<Operation> get(Annotation annotation, AnnotatedElement ae) {
        IRecords records = (IRecords) annotation;
        return Arrays.stream(records.value()).map(v -> IRecordOperation.annotationToThis(v, ae.toString())).collect(Collectors.toList());
    }
}
